#include "head.h"
void equal(LNode* Node, book& book) {
	Node->data.id = book.id;
	Node->data.name = book.name;
	Node->data.price = book.price;
}



LNode* creatList() {
	LNode* headNode = new LNode;
	//headNode->data = 0;
	headNode->next = nullptr;
	return headNode;
}



void InsertNodeByhead(LNode* headNode, book& data) {
	LNode* newNode = new LNode;
	/*newNode->data.id = data.id;
	newNode->data.id = data..name;
	newNode->data.id = data..price;*/
	equal(newNode, data);
	newNode->next = headNode->next;
	headNode->next = newNode;
}

void InsertNodeBytail(LNode* head, book data) {
	if (head->next == nullptr)
		return;
	LNode* pMove = head->next;
	assert(pMove);
	while (pMove->next != nullptr) {
		pMove = pMove->next;
	}
	LNode* newNode = new LNode;
	//newNode->data = data;
	equal(newNode, data);
	newNode->next = nullptr;
	pMove->next = newNode;
}

//void searchBookByname(LNode* headNode, book& name) {
//	LNode* pMove = headNode->next;
//	while (strcmp(pMove->data.name, name.name)) {
//		;
//	}
//}
void printList(LNode* head) {
	LNode* pMove = head->next;
	while (pMove) {
		cout << pMove->data.id << " " << pMove->data.name << " " << pMove->data.price << endl;;
		pMove = pMove->next;
	}
	cout << "\n";
}